﻿<!DOCTYPE HTML>
<html lang="zh">
<head>
<title>FileGetTime - 语法 &amp; 使用 | AutoHotkey v2</title>
<meta name="description" content="The FileGetTime function retrieves the datetime stamp of a file or folder." />
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<link href="../static/theme.css" rel="stylesheet" type="text/css" />
<script src="../static/content.js" type="text/javascript"></script>
<script type="text/javascript">$(function(){0<=window.navigator.userAgent.toLowerCase().indexOf("ucbrowser")&&CaoNiMaDeUc()})</script>
</head>
<body>

<h1>FileGetTime</h1>

<p>获取文件或文件夹的时间戳.</p>

<pre class="Syntax">Timestamp := <span class="func">FileGetTime</span>(<span class="optional">Filename, WhichTime</span>)</pre>
<h2 id="Parameters">参数</h2>
<dl>

  <dt>Filename</dt>
  <dd>
    <p>类型: <a href="../Concepts.htm#strings">字符串</a></p>
    <p>目标文件或文件夹的名称, 如果未指定绝对路径则假定在 <a href="../Variables.htm#WorkingDir">A_WorkingDir</a> 中. 如果省略, 则使用最内层<a href="LoopFile.htm">文件循环</a>的当前文件.</p>
  </dd>

  <dt>WhichTime</dt>
  <dd>
    <p>类型: <a href="../Concepts.htm#strings">字符串</a></p>
    <p>要获取的时间戳类别:<br>
        M = 修改时间(此参数省略时这是默认的)<br>
        C = 创建时间<br>
        A = 上次访问时间</p>
  </dd>

</dl>

<h2 id="Return_Value">返回值</h2>
<p>类型: <a href="../Concepts.htm#strings">字符串</a></p>
<p>函数返回 <a href="FileSetTime.htm#YYYYMMDD">YYYYMMDDHH24MISS</a> 格式的数字字符串. 这个时间是您的本地时间, 不是 UTC/GMT. 此字符串不应视为数字(不应对其进行数学运算或进行数值比较).</p>

<h2 id="Error_Handling">错误处理</h2>
<p>失败时抛出异常.</p>
<p><a href="../Variables.htm#LastError">A_LastError</a> 被设置为操作系统 GetLastError() 函数返回的结果.</p>

<h2 id="Remarks">备注</h2>
<p>有关日期和时间的说明, 请参阅 <a href="FileSetTime.htm#YYYYMMDD">YYYYMMDDHH24MISS</a>.</p>
<h2 id="Related">相关</h2>
<p><a href="FileSetTime.htm">FileSetTime</a>, <a href="FormatTime.htm">FormatTime</a>, <a href="FileGetAttrib.htm">FileGetAttrib</a>, <a href="FileSetAttrib.htm">FileSetAttrib</a>, <a href="FileGetSize.htm">FileGetSize</a>, <a href="FileGetVersion.htm">FileGetVersion</a>, <a href="LoopFiles.htm">File-loop</a>, <a href="DateAdd.htm">DateAdd</a>, <a href="DateDiff.htm">DateDiff</a></p>
<h2 id="Examples">示例</h2>
<div class="ex" id="ExBasic">
<p><a href="#ExBasic">#1</a></p>
<pre>Timestamp := FileGetTime("C:\My Documents\test.doc")  <em>; 默认获取修改时间.</em>
Timestamp := FileGetTime("C:\My Documents\test.doc", "C")  <em>; 获取创建时间.</em></pre>
</div>

</body>
</html>